package cn.dingdan.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.dingdan.pojo.Dishes;
import cn.dingdan.sercice.DishesService;
import cn.dingdan.tools.PageSupport;

@Controller
@RequestMapping("/dishes")
public class GetDishesController {
	
	@Resource(name="dishesServiceImpl")
	private DishesService dishesService;
	
	/*
	 *按照类进行分类查寻
	 */
	@RequestMapping("/getDishesList")
	public @ResponseBody PageSupport getDishesList(@RequestParam(value="menuTypeId",required=false)Integer menuTypeId,
			@RequestParam(value="currentPageNo",required=false,defaultValue="1")Integer currentPageNo){
		PageSupport page=new PageSupport();
		page.setCurrentPageNo(currentPageNo);
		page.setPageSize(12);
		page.setTotalCount(dishesService.getDishesSize(menuTypeId));
		List<Dishes> list=dishesService.getLists(menuTypeId, page);
		page.setList(list);
		return page;
	}
	/*
	 * 获取值进行模糊查询
	 */
	@RequestMapping("/getInDishesList")
	public @ResponseBody List<Dishes> getInDishesList(@RequestParam(value="InName")String InName){
		List<Dishes> dishes=dishesService.getInDishesList(InName);
		return dishes;
	}
}
